package com.headwind;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * SpringBoot启动类
 *
 * @author Headwind
 * @version 1.0
 * @date Created in 2020/7/12
 */
@RestController
@SpringBootApplication
@EnableAsync
public class SpringBootLearningApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootLearningApplication.class, args);
    }


    /**
     * 返回 Hello ${name}！
     *
     * @param name 非必须
     * @return hello ${name}!
     */
    @GetMapping(value = "/hello")
    @Async
    public String sayHello(@RequestParam(required = false, name = "name") String name) {
        if (StringUtils.isEmpty(name)) {
            name = "World";
        }
        return String.format("Hello %s!", name);
    }
}
